local Rune = class("Rune")

function Rune:ctor( data )
	self.id = 0 -- id
	self.equipState = 0 -- 装配状态(0-未装配 1-已装配) -1-未获得（客户端添加）

	self.isNew = false
	self.conf = nil -- 配表中数据

	if data then
		self:read( data )
	end
end

function Rune:read( value )
	local preId = self.id
	self.id = value.id
	self.equipState = value.equipState or -1

	if not self.conf and self.id ~= preId then
		self.conf = GD:queryRuneById( self.id )
		assert(self.conf ~= nil, "Rune.conf can't be nil " .. tostring( self.id ) )

		self._skillIcon = nil
		self._skillName = nil
	end
end

function Rune:getId()
	return self.id
end

function Rune:clearEquipState()
	self.equipState = -1
end

-- 是否装备中
function Rune:isEquiped()
	return 1 == self.equipState
end

-- 是否已获得
function Rune:isGot()
	return self.equipState >= 0
end


function Rune:getName()
	return L( self.conf.name )
end

function Rune:getDesc()
	return L( self.conf.des )
end

function Rune:getSpecId()
	return tonumber( self.conf.class )
end

function Rune:getUserLv()
	return tonumber( self.conf.useLv )
end

-- 相对于原生技能等级增加的技能（用来计算原生技能等级）
function Rune:getAddLv()
	return tonumber(self.conf.addLevel)
end

function Rune:getQuality()
	return tonumber( self.conf.quality )
end

function Rune:getScore()
	return tonumber( self.conf.RuneScore )
end

function Rune:getEquipPlace()
	return tonumber( self.conf.equipPlace )
end

function Rune:getResource()
	local resource = GD:getConvertResource(self.conf.getResource)
	return resource
end

function Rune:getIcon()
	return table.concat( { Res.runeIconPath, self.conf.icon, ".png" } )
end

function Rune:_initSkillParams()
	if not self._skillIcon then
		local skillConf = GD:getFirstSkillConfByTeam(self:getSkillTeam())
		self._skillIcon = table.concat({Res.skillIconPath, skillConf.icon, ".png"})
		self._skillName = L(skillConf.name)
		self._skillDesc = L(skillConf.des or "")
	end
end

-- 符文对应的技能icon
function Rune:getSkillIcon()
	self:_initSkillParams()
	return self._skillIcon
end

-- 符文对应的技能name
function Rune:getSkillName()
	self:_initSkillParams()
	return self._skillName
end

-- 符文对应的技能name
function Rune:getSkillDesc()
	self:_initSkillParams()
	return self._skillDesc
end

function Rune:getIconBg()
end

-- 返回原技能Id
function Rune:getSkillTeam()
	return tonumber(self.conf.team)
end

function Rune:setIsNewGet(isNew)
	self.isNew = isNew
end

return Rune
